#!/bin/sh
if [ -z $1 ];then
hive_db=default
else
hive_db=$1
fi

if [ -z $2 ];then
create_time=`date  "+%Y-%m-%d %H-%M-%S"`
else
create_time=$2
fi

hiveconfig=$(cat <<"EOF" /home/hdfs/parquet_shell/hive_parquet_scripts/hive.config
EOF
)

sql_suffix=$(cat <<EOF
        INSERT INTO TABLE dongfeng.navinfo_parquet_d005 PARTITION (part_time) SELECT time,longitude,latitude,temperature,atmosphericPressure,speed,mile,accelerator,handBrake,footBrake,acc,mil,fuelLevel,intakeManifoldPressure,intakeManifoldTemp,oilPressuer,voltage,totalFuelConsumption,ureaVoltage,fuelTemp,coolantTemp,intakeFlow,intakeTemp,realTimeOilConsumption,engineTorMode,actualEnginePercentTor,frictionEnginePercentTor,idlingTor,actualInnerPercentTor,referenceTor,rotation,realtimeFuelInjection,engineStartMode,cumulativeRunningTime,cumulativeRotation,activeLimitType,fuelQuality,ureaLevel,ureaTemp,actualBlueSpout,intakeOxynitrideValue,aftertreatOxynitrideContr,totalUreaConsumption,scrSubsystemStatus,ureaPumpDutyfactor,ureaSprayerDutyfactor,ureaLevelSignalCheck,aftertreatUpstreamExhaustTemp,catalystDownStreamTemp,upstreamExhausTempSignalCheck,aftertreatDewpointSts,tailPipeOxynitrideDewPointSts,noxSensorSignalCheck,intakeOxygenContent,exhaustOxygenContent,pumpRotation,pumpStatus,intakePressure,intakeTempPoc,exhaustPressure,exhaustTemp,carrierPressureDifferential,wasteGasQuantityFlow,aftertreatRealtimeInjection,tailpipeRealtimeOxynitrideContr,pemsNoxExhaust,ecuTamperDetection,terminalId,serialNumber,'${create_time}',part_time  FROM dongfeng.navinfo_parquet_d005_temp;
EOF
)
sql="${hiveconfig}${sql_suffix}"
############  execute begin   ###########
hive -e  "$sql"
#echo $sql
